{% extends "base.html" %}

{% block titulo %}Foro del Curso - {{course.name}} - grupo {{group.code}} {% endblock %}

{%block style%}<link rel="stylesheet" type="text/css" href="/stylesheets/forumStyle.css" />{%endblock%}

{% block breadcrumbs %}<div id="middleBreadcrumb"><a href="/home/">home</a> ></div>
                        <div id="middleBreadcrumb"><a href="/course/{{course.code}}/{{group.code}}/">{{course.name}}</a> ></div>
                        <div id="lastBreadcrumb">foro</div>{% endblock %}

{% block cuerpo %}
    {%if isTeacher%}
    <form method="get" action="/crearTema/{{course.code}}/{{group.code}}/">
        <input type="submit" value="Crear Tema" />
    </form>
    <hr />
    {%endif%}
    
    <div id="forum_container">
        <table id="rounded-corner">
            <thead>
                <tr>
                    <th scope="col" class="icon"></th>
                    <th scope="col" class="title">Tema</th>
                    <th scope="col" class="created">Creado</th>
                    <th scope="col" class="replies">Aportaciones</th>
                    <th scope="col" class="last_post">&Uacute;ltima aportaci&oacute;n</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <td class="rounded-foot-left"></td>
                    <td colspan="3" class="rounded-foot-center"></td>
                    <td class="rounded-foot-right"></td>
                </tr>
            </tfoot>
            <tbody>
                {%for thread in threadList%}
                <tr class="{%cycle 'a' 'b' %}" onclick="getLink('/thread/{{thread.id}}/')">
                    <td>
                        <div id="thread_icon"><img src="/resources/webImages/thread.png" width="32" height="32" /></div>
                    </td>
                    <td>
                        <div id="thread">
                            <div id="thread_title"><a href="/thread/{{thread.id}}/">{{thread.title}}</a></div>
                            <div id="thread_desc">{{thread.description}}</div>
                        </div>
                    </td>
                    <td>
                        <div id="thread_creation_date">{{thread.date|date:"M d, f a"}}</div>
                    </td>
                    <td>
                        <div id="thread_post_number">{{thread.postNumber}}</div>
                    </td>
                    <td>
                        {%if thread.lastPost%}
                            <div id="last_post">
                                <div id="last_post_date">{{thread.lastPost.date|date:"M d, f a"}}</div>
                                <div id="last_post_author">{{thread.lastPost.creator.get_full_name}}</div>
                            </div>
                        {%else%}
                            <div id="last_post">
                                <div id="last_post_author">No hay aportaciones en este tema.</div>
                            </div>
                        {%endif%}
                    </td>
                </tr>
                {%endfor%}
            </tbody>
        </table>
    </div>
    
{% endblock %}
